<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>发布活动 - 黄淮学院校园活动管理系统</title>
    <!-- Tailwind CSS -->
    <script src="https://cdn.tailwindcss.com"></script>
    <!-- Font Awesome -->
    <link href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!-- 自定义配置 -->
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#165DFF',
                        secondary: '#0FC6C2',
                        success: '#00B42A',
                        warning: '#FF7D00',
                        danger: '#F53F3F',
                        info: '#86909C',
                        dark: '#1D2129',
                        light: '#F2F3F5'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .card-hover {
                @apply transition-all duration-300 hover:shadow-lg hover:-translate-y-1;
            }
            .btn-primary {
                @apply bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-all;
            }
            .btn-secondary {
                @apply bg-white border border-primary text-primary px-4 py-2 rounded-lg hover:bg-primary/5 transition-all;
            }
            .btn-danger {
                @apply bg-danger text-white px-4 py-2 rounded-lg hover:bg-danger/90 transition-all;
            }
            .btn-outline {
                @apply bg-white border border-gray-300 text-gray-700 px-4 py-2 rounded-lg hover:bg-gray-50 transition-all;
            }
            .nav-item {
                @apply px-4 py-2 rounded-lg transition-all hover:bg-primary/10 cursor-pointer;
            }
            .nav-item-active {
                @apply bg-primary/10 text-primary font-medium;
            }
            .form-input {
                @apply w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all;
            }
            .form-label {
                @apply block text-sm font-medium text-gray-700 mb-1;
            }
            .form-error {
                @apply text-danger text-xs mt-1;
            }
            .badge {
                @apply px-2 py-1 text-xs rounded-full;
            }
            .step-item {
                @apply relative flex flex-col items-center;
            }
            .step-number {
                @apply w-10 h-10 rounded-full bg-gray-200 flex items-center justify-center text-gray-500 font-medium mb-2 z-10 transition-all;
            }
            .step-number-active {
                @apply bg-primary text-white;
            }
            .step-line {
                @apply absolute top-5 left-1/2 w-full h-0.5 bg-gray-200 -z-0 transition-all;
            }
            .step-line-active {
                @apply bg-primary;
            }
            .step-title {
                @apply text-sm text-gray-500 transition-all;
            }
            .step-title-active {
                @apply text-primary font-medium;
            }
            .upload-box {
                @apply border-2 border-dashed border-gray-200 rounded-lg p-8 text-center cursor-pointer transition-all hover:border-primary hover:bg-gray-50;
            }
        }
    </style>
</head>
<body class="bg-gray-50 text-dark">
<!-- 顶部导航栏 -->
<header id="navbar" class="fixed top-0 left-0 right-0 bg-white shadow-sm z-50 transition-all duration-300">
    <div class="container mx-auto px-4">
        <div class="flex items-center justify-between h-16">
            <!-- Logo -->
            <div class="flex items-center space-x-2">
                <div class="w-10 h-10 bg-primary rounded-lg flex items-center justify-center">
                    <i class="fa fa-graduation-cap text-white text-xl"></i>
                </div>
                <div>
                    <h1 class="text-xl font-bold text-primary">黄淮学院</h1>
                    <p class="text-xs text-info">校园活动管理系统</p>
                </div>
            </div>

            <!-- 导航链接 - 桌面端 -->
            <nav class="hidden md:flex items-center space-x-2">
                <a href="index.html" class="nav-item">首页</a>
                <a href="activities.html" class="nav-item">活动列表</a>
                <a href="discover.html" class="nav-item">发现</a>
                <a href="about.html" class="nav-item">关于我们</a>
            </nav>

            <!-- 用户操作 -->
            <div class="flex items-center space-x-4">
                <button id="searchBtn" class="p-2 rounded-full hover:bg-gray-100 transition-all">
                    <i class="fa fa-search text-info"></i>
                </button>
                <button id="notificationsBtn" class="p-2 rounded-full hover:bg-gray-100 transition-all relative">
                    <i class="fa fa-bell text-info"></i>
                    <span class="absolute top-1 right-1 w-2 h-2 bg-danger rounded-full"></span>
                </button>
                <div id="userMenu" class="relative">
                    <button id="userMenuBtn" class="flex items-center space-x-2 hover:bg-gray-100 p-1 rounded-lg transition-all">
                        <img src="https://picsum.photos/id/1005/200/200" alt="用户头像" class="w-8 h-8 rounded-full object-cover border-2 border-primary/20">
                        <span class="hidden md:inline-block font-medium">张三</span>
                        <i class="fa fa-caret-down text-xs text-info"></i>
                    </button>
                    <!-- 用户下拉菜单 -->
                    <div id="userDropdown" class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-2 z-50 hidden">
                        <a href="#" class="block px-4 py-2 text-sm hover:bg-gray-100 transition-all">
                            <i class="fa fa-user-o mr-2 text-info"></i>个人中心
                        </a>
                        <a href="#" class="block px-4 py-2 text-sm hover:bg-gray-100 transition-all">
                            <i class="fa fa-calendar-check-o mr-2 text-info"></i>我的活动
                        </a>
                        <a href="#" class="block px-4 py-2 text-sm hover:bg-gray-100 transition-all">
                            <i class="fa fa-cog mr-2 text-info"></i>账号设置
                        </a>
                        <div class="border-t border-gray-100 my-1"></div>
                        <a href="login.html" class="block px-4 py-2 text-sm hover:bg-gray-100 transition-all">
                            <i class="fa fa-sign-out mr-2 text-info"></i>退出登录
                        </a>
                    </div>
                </div>
                <!-- 移动端菜单按钮 -->
                <button id="mobileMenuBtn" class="md:hidden p-2 rounded-lg hover:bg-gray-100 transition-all">
                    <i class="fa fa-bars text-info"></i>
                </button>
            </div>
        </div>
    </div>

    <!-- 搜索框 -->
    <div id="searchBox" class="container mx-auto px-4 pb-4 hidden">
        <div class="relative">
            <input type="text" placeholder="搜索活动、主办方..." class="w-full pl-10 pr-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary/50">
            <i class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-info"></i>
        </div>
    </div>

    <!-- 移动端导航菜单 -->
    <div id="mobileMenu" class="md:hidden container mx-auto px-4 pb-4 hidden">
        <nav class="flex flex-col space-y-1">
            <a href="index.html" class="nav-item">首页</a>
            <a href="activities.html" class="nav-item">活动列表</a>
            <a href="discover.html" class="nav-item">发现</a>
            <a href="about.html" class="nav-item">关于我们</a>
            <div class="pt-2 flex space-x-2">
                <a href="#" class="btn-primary flex-1 text-center">个人中心</a>
                <a href="login.html" class="btn-secondary flex-1 text-center">退出</a>
            </div>
        </nav>
    </div>
</header>

<!-- 主要内容 -->
<main class="container mx-auto px-4 pt-24 pb-16">
    <!-- 页面标题 -->
    <section class="mb-8">
        <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-4">
            <div>
                <h1 class="text-3xl font-bold mb-2">发布新活动</h1>
                <p class="text-info">填写以下信息发布校园活动，所有带 * 的字段为必填项</p>
            </div>
            <div class="flex gap-3">
                <button id="saveDraftBtn" class="btn-outline flex items-center gap-2">
                    <i class="fa fa-save"></i> 保存草稿
                </button>
                <button id="previewBtn" class="btn-secondary flex items-center gap-2">
                    <i class="fa fa-eye"></i> 预览
                </button>
            </div>
        </div>
    </section>

    <!-- 发布须知 -->
    <div class="bg-blue-50 border-l-4 border-primary p-4 rounded-r-lg mb-8">
        <h4 class="font-medium text-primary mb-2">发布须知</h4>
        <ul class="text-sm text-gray-600 space-y-1">
            <li class="flex items-start">
                <i class="fa fa-info-circle text-primary mt-0.5 mr-2"></i>
                <span>请确保活动信息真实有效，避免虚假信息</span>
            </li>
            <li class="flex items-start">
                <i class="fa fa-info-circle text-primary mt-0.5 mr-2"></i>
                <span>活动审核通过后将在24小时内上线</span>
            </li>
            <li class="flex items-start">
                <i class="fa fa-info-circle text-primary mt-0.5 mr-2"></i>
                <span>如需修改已发布的活动信息，请前往个人中心操作</span>
            </li>
            <li class="flex items-start">
                <i class="fa fa-info-circle text-primary mt-0.5 mr-2"></i>
                <span>活动封面图片建议尺寸为1200x400像素，大小不超过2MB</span>
            </li>
        </ul>
    </div>

    <!-- 步骤指示器 -->
    <section class="mb-10">
        <div class="flex justify-between relative">
            <!-- 步骤1 -->
            <div class="step-item flex-1">
                <div class="step-number step-number-active">1</div>
                <div class="step-title step-title-active">基本信息</div>
                <div class="step-line step-line-active"></div>
            </div>

            <!-- 步骤2 -->
            <div class="step-item flex-1">
                <div class="step-number">2</div>
                <div class="step-title">活动封面与详情</div>
                <div class="step-line"></div>
            </div>

            <!-- 步骤3 -->
            <div class="step-item flex-1">
                <div class="step-number">3</div>
                <div class="step-title">联系方式与提交</div>
            </div>
        </div>
    </section>

    <!-- 表单内容 -->
    <section class="bg-white rounded-xl shadow-sm p-6 md:p-8">
        <form id="publish-form">
            <!-- 步骤1：基本信息 -->
            <div id="step-1" class="step-content">
                <h2 class="text-xl font-bold mb-6 pb-2 border-b border-gray-100">基本信息</h2>

                <div class="space-y-6">
                    <div>
                        <label class="form-label" for="event-title">活动标题 *</label>
                        <input type="text" id="event-title" class="form-input" placeholder="请输入活动标题" required>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="form-label" for="event-type">活动类型 *</label>
                            <select id="event-type" class="form-input" required>
                                <option value="">请选择活动类型</option>
                                <option value="文化艺术">文化艺术</option>
                                <option value="学术科技">学术科技</option>
                                <option value="体育竞技">体育竞技</option>
                                <option value="社会实践">社会实践</option>
                                <option value="志愿服务">志愿服务</option>
                                <option value="讲座报告">讲座报告</option>
                                <option value="就业招聘">就业招聘</option>
                                <option value="其他">其他</option>
                            </select>
                        </div>
                        <div>
                            <label class="form-label" for="event-fee">活动费用 *</label>
                            <select id="event-fee" class="form-input" required>
                                <option value="免费">免费</option>
                                <option value="收费">收费</option>
                            </select>
                        </div>
                    </div>

                    <div id="fee-amount-container" class="hidden">
                        <label class="form-label" for="event-fee-amount">收费金额（元）</label>
                        <input type="number" id="event-fee-amount" class="form-input" placeholder="请输入收费金额" min="0" step="0.01">
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="form-label" for="event-start-time">开始时间 *</label>
                            <input type="datetime-local" id="event-start-time" class="form-input" required>
                        </div>
                        <div>
                            <label class="form-label" for="event-end-time">结束时间 *</label>
                            <input type="datetime-local" id="event-end-time" class="form-input" required>
                        </div>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="form-label" for="event-location">活动地点 *</label>
                            <input type="text" id="event-location" class="form-input" placeholder="请输入活动地点" required>
                        </div>
                        <div>
                            <label class="form-label" for="event-limit">报名人数限制</label>
                            <input type="number" id="event-limit" class="form-input" placeholder="不填则不限制" min="0">
                        </div>
                    </div>

                    <div>
                        <label class="form-label" for="event-reg-deadline">报名截止时间 *</label>
                        <input type="datetime-local" id="event-reg-deadline" class="form-input" required>
                    </div>
                </div>
            </div>

            <!-- 步骤2：活动封面与详情 -->
            <div id="step-2" class="step-content hidden">
                <h2 class="text-xl font-bold mb-6 pb-2 border-b border-gray-100">活动封面与详情</h2>

                <div class="space-y-6">
                    <!-- 活动封面 -->
                    <div>
                        <label class="form-label">活动封面 *</label>
                        <div class="upload-box mt-2">
                            <input type="file" id="event-cover" accept="image/*" class="hidden" required>
                            <div id="image-preview-container">
                                <i class="fa fa-image text-4xl text-info mb-3"></i>
                                <p class="text-gray-600 mb-1">点击或拖拽图片到此处上传</p>
                                <small class="text-info">支持 JPG、PNG 格式，大小不超过2MB</small>
                            </div>
                            <div id="uploaded-image-container" class="hidden">
                                <img id="preview-image" src="" alt="预览" class="w-full rounded-lg mb-3">
                                <button type="button" id="remove-image" class="btn-outline text-sm">
                                    <i class="fa fa-times mr-1"></i> 移除图片
                                </button>
                            </div>
                        </div>
                    </div>

                    <!-- 活动详情 -->
                    <div>
                        <label class="form-label" for="event-description">活动介绍 *</label>
                        <textarea id="event-description" class="form-input" placeholder="请详细描述活动内容、背景、目的等信息" rows="5" required></textarea>
                    </div>

                    <div>
                        <label class="form-label" for="event-process">活动流程</label>
                        <textarea id="event-process" class="form-input" placeholder="请描述活动的具体流程、时间安排等" rows="4"></textarea>
                    </div>

                    <div>
                        <label class="form-label" for="event-rules">参与规则</label>
                        <textarea id="event-rules" class="form-input" placeholder="请说明参与活动的规则、要求等" rows="4"></textarea>
                    </div>

                    <div>
                        <label class="form-label" for="event-rewards">奖项设置</label>
                        <textarea id="event-rewards" class="form-input" placeholder="如果活动有奖项设置，请在此说明" rows="4"></textarea>
                    </div>
                </div>
            </div>

            <!-- 步骤3：联系方式与提交 -->
            <div id="step-3" class="step-content hidden">
                <h2 class="text-xl font-bold mb-6 pb-2 border-b border-gray-100">联系方式</h2>

                <div class="space-y-6">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label class="form-label" for="contact-name">联系人 *</label>
                            <input type="text" id="contact-name" class="form-input" placeholder="请输入联系人姓名" required>
                        </div>
                        <div>
                            <label class="form-label" for="contact-phone">联系电话 *</label>
                            <input type="tel" id="contact-phone" class="form-input" placeholder="请输入联系电话" required>
                        </div>
                    </div>

                    <div>
                        <label class="form-label" for="contact-email">联系邮箱</label>
                        <input type="email" id="contact-email" class="form-input" placeholder="请输入联系邮箱">
                    </div>

                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h4 class="font-medium text-gray-700 mb-2">提交前请确认</h4>
                        <p class="text-sm text-gray-600">您已确保所有信息真实有效，提交后将进入审核流程，审核通过后活动将正式发布。</p>
                    </div>
                </div>
            </div>

            <!-- 步骤按钮 -->
            <div class="flex justify-between pt-6 border-t border-gray-100">
                <button type="button" id="prevStepBtn" class="btn-outline" disabled>上一步</button>
                <div>
                    <button type="button" id="nextStepBtn" class="btn-primary">下一步</button>
                    <button type="submit" id="submitBtn" class="btn-primary hidden">提交审核</button>
                </div>
            </div>
        </form>
    </section>
</main>

<!-- 页脚 -->
<footer class="bg-dark text-white py-12">
    <div class="container mx-auto px-4">
        <div class="grid grid-cols-1 md:grid-cols-4 gap-8 mb-8">
            <div>
                <div class="flex items-center space-x-2 mb-4">
                    <div class="w-10 h-10 bg-white rounded-lg flex items-center justify-center">
                        <i class="fa fa-graduation-cap text-primary text-xl"></i>
                    </div>
                    <h3 class="text-xl font-bold">黄淮学院</h3>
                </div>
                <p class="text-gray-400 text-sm mb-4">校园活动管理系统致力于为全校师生提供便捷的活动信息服务平台。</p>
                <div class="flex space-x-4">
                    <a href="#" class="w-8 h-8 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary transition-all">
                        <i class="fa fa-weibo"></i>
                    </a>
                    <a href="#" class="w-8 h-8 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary transition-all">
                        <i class="fa fa-wechat"></i>
                    </a>
                    <a href="#" class="w-8 h-8 rounded-full bg-white/10 flex items-center justify-center hover:bg-primary transition-all">
                        <i class="fa fa-qq"></i>
                    </a>
                </div>
            </div>
            <div>
                <h4 class="text-lg font-medium mb-4">快速链接</h4>
                <ul class="space-y-2 text-gray-400">
                    <li><a href="index.html" class="hover:text-white transition-all">首页</a></li>
                    <li><a href="activities.html" class="hover:text-white transition-all">活动列表</a></li>
                    <li><a href="discover.html" class="hover:text-white transition-all">发现</a></li>
                    <li><a href="about.html" class="hover:text-white transition-all">关于我们</a></li>
                </ul>
            </div>
            <div>
                <h4 class="text-lg font-medium mb-4">帮助中心</h4>
                <ul class="space-y-2 text-gray-400">
                    <li><a href="faq.html" class="hover:text-white transition-all">常见问题</a></li>
                    <li><a href="contact.html" class="hover:text-white transition-all">联系我们</a></li>
                    <li><a href="privacy.html" class="hover:text-white transition-all">隐私政策</a></li>
                    <li><a href="terms.html" class="hover:text-white transition-all">用户协议</a></li>
                </ul>
            </div>
            <div>
                <h4 class="text-lg font-medium mb-4">联系我们</h4>
                <ul class="space-y-3 text-gray-400">
                    <li class="flex items-start">
                        <i class="fa fa-map-marker mt-1 mr-3"></i>
                        <span>河南省驻马店市开源大道6号黄淮学院</span>
                    </li>
                    <li class="flex items-center">
                        <i class="fa fa-phone mr-3"></i>
                        <span>0396-2853611</span>
                    </li>
                    <li class="flex items-center">
                        <i class="fa fa-envelope mr-3"></i>
                        <span>contact@huanghuai.edu.cn</span>
                    </li>
                </ul>
            </div>
        </div>
        <div class="pt-8 border-t border-white/10 text-center text-gray-500 text-sm">
            <p>© 2023 黄淮学院校园活动管理系统 版权所有</p>
        </div>
    </div>
</footer>

<!-- 回到顶部按钮 -->
<button id="backToTop" class="fixed bottom-8 right-8 w-12 h-12 rounded-full bg-primary text-white shadow-lg flex items-center justify-center opacity-0 invisible transition-all">
    <i class="fa fa-angle-up text-xl"></i>
</button>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 导航栏交互（复用第一段代码逻辑）
        const navbar = document.getElementById('navbar');
        const searchBtn = document.getElementById('searchBtn');
        const searchBox = document.getElementById('searchBox');
        const mobileMenuBtn = document.getElementById('mobileMenuBtn');
        const mobileMenu = document.getElementById('mobileMenu');
        const userMenuBtn = document.getElementById('userMenuBtn');
        const userDropdown = document.getElementById('userDropdown');
        const backToTop = document.getElementById('backToTop');

        // 滚动效果
        window.addEventListener('scroll', function() {
            if (window.scrollY > 50) {
                navbar.classList.add('shadow');
                backToTop.classList.remove('opacity-0', 'invisible');
                backToTop.classList.add('opacity-100', 'visible');
            } else {
                navbar.classList.remove('shadow');
                backToTop.classList.add('opacity-0', 'invisible');
                backToTop.classList.remove('opacity-100', 'visible');
            }
        });

        // 回到顶部
        backToTop.addEventListener('click', function() {
            window.scrollTo({ top: 0, behavior: 'smooth' });
        });

        // 搜索框切换
        searchBtn.addEventListener('click', function() {
            searchBox.classList.toggle('hidden');
            if (!searchBox.classList.contains('hidden')) {
                searchBox.querySelector('input').focus();
            }
        });

        // 移动端菜单切换
        mobileMenuBtn.addEventListener('click', function() {
            mobileMenu.classList.toggle('hidden');
        });

        // 用户菜单切换
        userMenuBtn.addEventListener('click', function() {
            userDropdown.classList.toggle('hidden');
        });

        // 点击外部关闭下拉菜单
        document.addEventListener('click', function(e) {
            if (!userMenuBtn.contains(e.target) && !userDropdown.contains(e.target)) {
                userDropdown.classList.add('hidden');
            }
        });

        // 步骤切换逻辑
        const totalSteps = 3;
        let currentStep = 1;
        const prevBtn = document.getElementById('prevStepBtn');
        const nextBtn = document.getElementById('nextStepBtn');
        const submitBtn = document.getElementById('submitBtn');

        // 更新步骤显示
        function updateStep() {
            // 隐藏所有步骤
            document.querySelectorAll('.step-content').forEach((el, index) => {
                el.classList.add('hidden');
            });
            // 显示当前步骤
            document.getElementById(`step-${currentStep}`).classList.remove('hidden');

            // 更新步骤指示器
            document.querySelectorAll('.step-number').forEach((el, index) => {
                if (index + 1 < currentStep) {
                    el.classList.add('step-number-active');
                } else if (index + 1 === currentStep) {
                    el.classList.add('step-number-active');
                } else {
                    el.classList.remove('step-number-active');
                }
            });

            document.querySelectorAll('.step-title').forEach((el, index) => {
                if (index + 1 === currentStep) {
                    el.classList.add('step-title-active');
                } else {
                    el.classList.remove('step-title-active');
                }
            });

            document.querySelectorAll('.step-line').forEach((el, index) => {
                if (index + 1 < currentStep) {
                    el.classList.add('step-line-active');
                } else {
                    el.classList.remove('step-line-active');
                }
            });

            // 更新按钮状态
            prevBtn.disabled = currentStep === 1;
            if (currentStep === totalSteps) {
                nextBtn.classList.add('hidden');
                submitBtn.classList.remove('hidden');
            } else {
                nextBtn.classList.remove('hidden');
                submitBtn.classList.add('hidden');
            }

            // 滚动到顶部
            window.scrollTo({ top: 0, behavior: 'smooth' });
        }

        // 下一步
        nextBtn.addEventListener('click', function() {
            if (currentStep < totalSteps) {
                // 验证当前步骤
                if (currentStep === 1 && !validateStep1()) return;
                if (currentStep === 2 && !validateStep2()) return;

                currentStep++;
                updateStep();
            }
        });

        // 上一步
        prevBtn.addEventListener('click', function() {
            if (currentStep > 1) {
                currentStep--;
                updateStep();
            }
        });

        // 费用类型切换（复用第二段代码逻辑）
        const feeTypeSelect = document.getElementById('event-fee');
        const feeAmountContainer = document.getElementById('fee-amount-container');

        feeTypeSelect.addEventListener('change', function() {
            if (this.value === '收费') {
                feeAmountContainer.classList.remove('hidden');
            } else {
                feeAmountContainer.classList.add('hidden');
            }
        });

        // 图片上传处理（复用第二段代码逻辑）
        const fileInput = document.getElementById('event-cover');
        const uploadBox = document.querySelector('.upload-box');
        const imagePreviewContainer = document.getElementById('image-preview-container');
        const uploadedImageContainer = document.getElementById('uploaded-image-container');
        const previewImage = document.getElementById('preview-image');
        const removeImageBtn = document.getElementById('remove-image');

        uploadBox.addEventListener('click', function() {
            fileInput.click();
        });

        uploadBox.addEventListener('dragover', function(e) {
            e.preventDefault();
            this.classList.add('bg-primary/5');
        });

        uploadBox.addEventListener('dragleave', function() {
            this.classList.remove('bg-primary/5');
        });

        uploadBox.addEventListener('drop', function(e) {
            e.preventDefault();
            this.classList.remove('bg-primary/5');

            if (e.dataTransfer.files.length) {
                const file = e.dataTransfer.files[0];
                handleFile(file);
            }
        });

        fileInput.addEventListener('change', function() {
            if (this.files.length) {
                const file = this.files[0];
                handleFile(file);
            }
        });

        removeImageBtn.addEventListener('click', function() {
            fileInput.value = '';
            imagePreviewContainer.classList.remove('hidden');
            uploadedImageContainer.classList.add('hidden');
        });

        function handleFile(file) {
            // 验证文件类型和大小
            const validTypes = ['image/jpeg', 'image/png'];
            const maxSize = 2 * 1024 * 1024; // 2MB

            if (!validTypes.includes(file.type)) {
                alert('请上传 JPG 或 PNG 格式的图片');
                return;
            }

            if (file.size > maxSize) {
                alert('图片大小不能超过 2MB');
                return;
            }

            // 预览图片
            const reader = new FileReader();
            reader.onload = function(e) {
                previewImage.src = e.target.result;
                imagePreviewContainer.classList.add('hidden');
                uploadedImageContainer.classList.remove('hidden');
            };
            reader.readAsDataURL(file);
        }

        // 表单验证（复用第二段代码逻辑）
        function validateStep1() {
            // 验证必填项
            const requiredFields = [
                'event-title', 'event-type', 'event-fee',
                'event-start-time', 'event-end-time',
                'event-location', 'event-reg-deadline'
            ];

            for (const id of requiredFields) {
                const field = document.getElementById(id);
                if (!field.value.trim()) {
                    alert('请填写所有必填项');
                    field.focus();
                    return false;
                }
            }

            // 验证时间逻辑
            const startTime = new Date(document.getElementById('event-start-time').value);
            const endTime = new Date(document.getElementById('event-end-time').value);
            const deadlineTime = new Date(document.getElementById('event-reg-deadline').value);
            const now = new Date();

            if (startTime < now) {
                alert('活动开始时间不能早于当前时间');
                return false;
            }

            if (endTime <= startTime) {
                alert('活动结束时间必须晚于开始时间');
                return false;
            }

            if (deadlineTime > startTime) {
                alert('报名截止时间必须早于活动开始时间');
                return false;
            }

            return true;
        }

        function validateStep2() {
            // 验证封面图片
            if (!fileInput.files.length) {
                alert('请上传活动封面图片');
                return false;
            }

            // 验证活动介绍
            const desc = document.getElementById('event-description');
            if (!desc.value.trim()) {
                alert('请填写活动介绍');
                desc.focus();
                return false;
            }

            return true;
        }

        function validateForm() {
            // 验证联系方式
            const contactName = document.getElementById('contact-name');
            const contactPhone = document.getElementById('contact-phone');

            if (!contactName.value.trim()) {
                alert('请填写联系人姓名');
                contactName.focus();
                return false;
            }

            // 验证手机号
            const phoneRegex = /^1[3-9]\d{9}$/;
            if (!phoneRegex.test(contactPhone.value)) {
                alert('请输入正确的手机号码');
                contactPhone.focus();
                return false;
            }

            // 验证邮箱（如果填写）
            const emailField = document.getElementById('contact-email');
            if (emailField.value.trim()) {
                const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                if (!emailRegex.test(emailField.value)) {
                    alert('请输入正确的邮箱地址');
                    emailField.focus();
                    return false;
                }
            }

            return true;
        }

        // 表单提交
        document.getElementById('publish-form').addEventListener('submit', function(e) {
            e.preventDefault();

            if (validateForm()) {
                alert('活动发布成功，请等待审核！');
                window.location.href = 'activities.html';
            }
        });

        // 保存草稿
        document.getElementById('saveDraftBtn').addEventListener('click', function() {
            alert('活动草稿已保存');
        });

        // 预览
        document.getElementById('previewBtn').addEventListener('click', function() {
            alert('预览功能：活动信息将按发布后样式展示');
        });
    });
</script>
</body>
</html>